Page({
  data: {
    TabCur1: 0,
    TabCur2: 0,
    TabCur3: 0,
    scrollLeft1: 0,
    scrollLeft2: 0,
    scrollLeft3: 0,
    x:null,
    y:null,
    seleted: null,
    picClass:[{name:"柱状图"},{name:"折线图"},{name:"扇形图"}],
    xAxisHistogram: [{ name: "种类" }, { name: "商品" }, { name: "日" }, { name: "周" }, { name: "月" }],
    y1AxisHistogram: [{ name: "销售额" }, { name: "利润" }, { name: "成本" }, { name: "销售数量" }, { name: "库存量" }],
    y2AxisHistogram: [{ name: "销售额" }, { name: "利润" }, { name: "成本" }, { name: "销售数量" }],
    xAxisBrokenLineDiagram: [{ name: "日" }, { name: "周" }, { name: "月" }],
    yAxisBrokenLineDiagram: [{ name: "销售额" }, { name: "利润" }, { name: "成本" }],
    xAxisFanChart: [{ name: "种类" }, { name: "天" }, { name: "周" }, { name: "月" }],
    y1AxisFanChart: [{ name: "销量" }, { name: "营业额" }, { name: "利润" }, { name: "库存量" }],
    y2AxisFanChart: [{ name: "销量" }, { name: "营业额" }, { name: "利润" }],
  },

  tabSelect1(e) {
    console.log(e.currentTarget.dataset);
    var that=this;
    var dataset = e.currentTarget.dataset;
    console.log(dataset.name);

    if (dataset.name == that.data.picClass[that.data.TabCur1].name) {
      console.log("重复");
    }else {
      console.log("不重复");
      if (dataset.id==0) {
        this.setData({
          TabCur1: e.currentTarget.dataset.id,
          scrollLeft1: (e.currentTarget.dataset.id - 1) * 60,
          x: that.data.xAxisHistogram,
          y: that.data.y1AxisHistogram,
          TabCur2: 0,
          scrollLeft2: 0,
          TabCur3: 0,
          scrollLeft3: 0,
        })
      } else if (dataset.id == 1) {
        this.setData({
          TabCur1: e.currentTarget.dataset.id,
          scrollLeft1: (e.currentTarget.dataset.id - 1) * 60,
          x: that.data.xAxisBrokenLineDiagram,
          y: that.data.yAxisBrokenLineDiagram,
          TabCur2: 0,
          scrollLeft2: 0,
          TabCur3: 0,
          scrollLeft3: 0,
        })
      } else if (dataset.id == 2) {
        this.setData({
          TabCur1: e.currentTarget.dataset.id,
          scrollLeft1: (e.currentTarget.dataset.id - 1) * 60,
          x: that.data.xAxisFanChart,
          y: that.data.y1AxisFanChart,
          TabCur2: 0,
          scrollLeft2: 0,
          TabCur3: 0,
          scrollLeft3: 0,
        })       
      }
    }
    that.getSeleted();
  },

  tabSelect2(e) {
    console.log(e.currentTarget.dataset);
    var that = this;
    var dataset = e.currentTarget.dataset;
    console.log(dataset.name);
    
    if (dataset.name == that.data.x[that.data.TabCur2].name) {
      console.log("重复");
    }else {
      console.log("不重复");
      if(that.data.TabCur1 == 0) {
        if (dataset.id == 0 || dataset.id == 1) {
          this.setData({
            TabCur2: e.currentTarget.dataset.id,
            TabCur3: 0,
            scrollLeft2: (e.currentTarget.dataset.id - 1) * 60,
            x: that.data.xAxisHistogram,
            y: that.data.y1AxisHistogram,
          })
        } else if (dataset.id == 2 || dataset.id == 3 || dataset.id == 4) {
          this.setData({
            TabCur2: e.currentTarget.dataset.id,
            TabCur3: 0,
            scrollLeft2: (e.currentTarget.dataset.id - 1) * 60,
            x: that.data.xAxisHistogram,
            y: that.data.y2AxisHistogram,
          })
        }
      } else if (that.data.TabCur1 == 1) {
        this.setData({
          TabCur2: e.currentTarget.dataset.id,
          TabCur3: 0,
          scrollLeft2: (e.currentTarget.dataset.id - 1) * 60
        })
      } else if (that.data.TabCur1 == 2) {
        if (dataset.id == 0){
          this.setData({
            TabCur2: e.currentTarget.dataset.id,
            TabCur3:0,
            scrollLeft2: (e.currentTarget.dataset.id - 1) * 60,
            y: that.data.y1AxisFanChart,
          })
        } else if (dataset.id == 1 || dataset.id == 2 || dataset.id == 3) {
          this.setData({
            TabCur2: e.currentTarget.dataset.id,
            TabCur3:0,
            scrollLeft2: (e.currentTarget.dataset.id - 1) * 60,
            y: that.data.y2AxisFanChart,
          })
        }
      }
    }
    that.getSeleted();
  },

  tabSelect3(e) {
    console.log(e.currentTarget.dataset.name);
    var that = this;
    this.setData({
      TabCur3: e.currentTarget.dataset.id,
      scrollLeft3: (e.currentTarget.dataset.id - 1) * 60
    })
    that.getSeleted();
  },

  getSeleted:function(e) {
    var s = [];
    var that = this;
    s.push(that.data.picClass[that.data.TabCur1]);
    s.push(that.data.x[that.data.TabCur2]);
    s.push(that.data.y[that.data.TabCur3]);
    that.setData({
      seleted: s,
    })
  },

  onLoad() {
    var that = this;
    var s = [];
    that.setData({
      x: that.data.xAxisHistogram,
      y: that.data.y1AxisHistogram,
    })
    s.push(that.data.picClass[that.data.TabCur1]);
    s.push(that.data.x[that.data.TabCur2]);
    s.push(that.data.y[that.data.TabCur3]);
    that.setData({
      seleted:s,
    })
  },
})